<?php
/**
 * Created by PhpStorm.
 * User: UGLY
 * Date: 2017/12/26
 * Time: 15:54
 */

namespace app\blog\controller;

use cmf\controller\AdminBaseController;

class CommonController extends AdminBaseController
{
    //二维码生成方法
    public function code($url = "https://www.baidu.com/", $level = 3, $size = 15,$name)
    {
        vendor('phpqrcode.phpqrcode');
        //容错级别
        $errorCorrectionLevel = intval($level);
        //生成图片大小
        $matrixPointSize = intval($size);
        //生成二维码图片
        $object = new \QRcode();
        //第二个参数false的意思是不生成图片文件，如果你写上‘picture.png’则会在根目录下生成一个png格式的图片文件
        $object->png($url, './two_code/'.$name.'.png', $errorCorrectionLevel, $matrixPointSize, 2);
    }
}